package com.aqie.seckill.controller;

import com.aqie.seckill.rabbitmq.MQSender;
import com.aqie.seckill.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/mq")
public class RabbitMQController {

    @Autowired
    MQSender sender;

    @RequestMapping("/hello")
    @ResponseBody
    public Result<String> mq(){
        sender.send("hello world");
        return Result.success(" Test MQ send!");
    }

    @RequestMapping("/topic")
    @ResponseBody
    public Result<String> topic() {
		sender.sendTopic("hello,topic");
        return Result.success("Hello，TOPIC");
    }

    @RequestMapping("/fanout")
    @ResponseBody
    public Result<String> fanout() {
		sender.sendFanout("hello,fanout");
        return Result.success("Hello，FANOUT");
    }

    @RequestMapping("/header")
    @ResponseBody
    public Result<String> header() {
		sender.sendHeader("hello,HEADER");
        return Result.success("Hello，header");
    }
}
